import request from '@/utils/request';
// 登录
export function login(data) {
  let formData = new FormData();
  formData.append('username', data.username);
  formData.append('password', data.password);
  return request({
    url: '/user/login',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data',
    },
  });
}
// 退出
export function loginout() {
  return request({
    url: '/user/logout',
    method: 'post',
  });
}
// 重置密码
export function resetPsd(data) {
  return request({
    url: '/user/update',
    method: 'post',
    data: {
      id: data.id,
      username: data.username,
      password: data.newPassword,
      oldPassword: data.oldPassword,
    },
  });
}
// 用户管理
// 查询列表
export function getDataList(data) {
  return request({
    url: '/user/list',
    method: 'get',
    params: data,
  });
}
// 删除
export function delDataList(ids) {
  return request({
    url: '/user/delete',
    method: 'post',
    data: ids,
  });
}
// 查看
export function getDataInfo(id) {
  return request({
    url: `/user/info/${id}`,
    method: 'get',
  });
}
// 新增 & 修改
export function savaDataInfo(data) {
  return request({
    url: `/user/${!data.id ? 'save' : 'update'}`,
    method: 'post',
    data: data,
  });
}

// 获取医护人员列表
export function getCareList() {
  return request({
    url: '/user/getCareList',
    method: 'get',
  });
}
